package com.kaduoxee.ebooks.controller;

import com.kaduoxee.ebooks.entity.User;
import com.kaduoxee.ebooks.service.impl.FictionServiceImpl;
import com.kaduoxee.ebooks.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private FictionServiceImpl fictionService;


    @PostMapping("/test")
    @ResponseBody
    public String test(){
        return "success";
    }

    @GetMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello ebook";
    }

    @GetMapping("/code")
    public String code(){
        return "common/code";
    }

    @RequestMapping("/index")
    public String index(Model model){
        model.addAttribute("list", fictionService.list());
        return "index/index";
    }


}
